package glue_datasyncer

import (
	streamCtx "gluenet/internal/glue-datasyncer/context"
	"io/ioutil"
)

func ReciverMetricsStream(c *streamCtx.StreamContext) {
	data, err := ioutil.ReadAll(c.ResquestReader.Body)
	if err != nil {
		c.ResponseWriter.Write([]byte("write failt " + err.Error()))
		c.Logger.Errorf("read remote write error")
	}
	c.MetricsChan <- data
	c.ResponseWriter.Write([]byte("write succeed"))
}

func ReciverLogsStream(c *streamCtx.StreamContext) {
	data, err := ioutil.ReadAll(c.ResquestReader.Body)
	if err != nil {
		c.ResponseWriter.Write([]byte("write failt " + err.Error()))
		c.Logger.Errorf("read remote write error")
	}
	c.LogsChan <- data
	c.ResponseWriter.Write([]byte("write succeed"))
}
